package com.bayihouse.model.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.bayihouse.model.excel.publicClass.BaseFatherOneEntity;
import com.bayihouse.model.excel.publicClass.BaseOneEntity;
import com.bayihouse.model.excel.publicClass.father.BaseEntity;
import com.bayihouse.utils.MyObjectUtils;
import lombok.*;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * @TableName room
 */
@TableName(value = "room")
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
@EqualsAndHashCode
public class Room extends BaseFatherOneEntity<Occupant> implements Serializable {


    /**
     * 房子的类型,是否用于租房
     */
    private Integer category;

    /**
     * 几楼
     */
    private Integer height;

    /**
     * 标签-有无地下室
     */
    private String label;

    private String address;

    private Long communityId;


    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 信息更新时间
     */
    private Date updateTime;

    /**
     * 是否已删除
     */
    @TableLogic
    private Integer isDelete;

    /**
     * 备注-房子的信息
     */
    private String detail;

    /**
     * 户主
     */
    private Long householdId;

    private Long unitId;


    private Long mannagerId;

    private String district;


    private String street;

    private String certNumber;

    private Date rentTime;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;


    /**
     * 房东
     */
    @Override
    public void setFId() {
        if (super.checkIsEmptyF()) {
            return;
        }
        super.father.setRoomId(super.id);
        if (MyObjectUtils.isNull(super.id)) {
            return;
        }
        this.setHouseholdId(super.id);
    }


    /**
     * 入住的人员
     */
    @Override
    public void setCId() {
        if (super.checkIsEmptyCList()) {
            return;
        }
        super.childrenList.stream().forEach(child -> {
            child.setRoomId(super.id);
        });
    }


}